package edu.hcmus.sow.utils;

import org.springframework.security.core.context.SecurityContextHolder;

import edu.hcmus.sow.domain.security.CustomUser;

public class SecurityUtil {

   public static Integer getCurrentClient() {
      CustomUser user = (CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

      // get current client id by sub domain
      Integer clientID = user.getClientID();
      return clientID;
   }

   public static Integer getCurrentLoggedinUserID() {
      CustomUser user = (CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

      // get logged in user id
      Integer userID = user.getUserID();

      return userID;
   }
}
